package com.wn.controller;

import com.common.entity.PageParam;
import com.common.entity.Programme;
import com.common.entity.Rsp;
import com.github.pagehelper.PageInfo;
import com.wn.service.ProgrammeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;


@RestController
public class ProgrammeController {

    @Autowired
    ProgrammeService programmeService;

    /**
     * @ClassName
     * @Description : 分页查询方案信息
     * @param: pageParam
     * @Return :
     * @Author : 汪雄
     * @Date :
    */
    @PostMapping("ProgrammesearchSomeByPage")
    public Rsp ProgrammesearchSomeByPage(@RequestBody PageParam<Programme> pageParam,
                                @RequestHeader("token")String token){
        PageInfo<Programme> pg = programmeService.searchSomeByPage(pageParam);
        return Rsp.success(pg);
    }


    /**
     * @ClassName
     * @Description : 查询所有方案
     * @param :
     * @Return :
     * @Author : 汪雄
     * @Date :
     */
    @PostMapping("searchAllProgramme")
    public List<Programme> searchAllProgramme(){
        return programmeService.searchAllProgramme();
    }

    /**
     * @ClassName
     * @Description :根据id查询方案信息
     * @param : id
     * @Return :
     * @Author : 汪雄
     * @Date :
    */
    @GetMapping("ProgrammegetOneById/{id}")
    public Rsp getOneById(@PathVariable("id") String id,
                          @RequestHeader("token")String token){
        Programme oneById = programmeService.getOneById(id);
        return Rsp.success(oneById);
    }

    /**
     * @ClassName
     * @Description : addOne添加方案
     * @param:
     * @Return :
     * @Author : 汪雄
     * @Date :
    */
    @PutMapping("ProgrammeaddOne")
    public Rsp addOne(@RequestBody Programme programme,
                      @RequestHeader("token")String token){
        return programmeService.addOne(programme);
    }

    /**
     * @ClassName
     * @Description : update修改方案
     * @param :
     * @Return :
     * @Author : 汪雄
     * @Date :
    */
    @PostMapping("Programmeupdate")
    public Rsp update(@RequestBody Programme programme,
                      @RequestHeader("token")String token){
        return programmeService.update( programme);
    }


    /**
     * @ClassName
     * @Description : deleteLogical逻辑删除方案
     * @param :
     * @Return :
     * @Author : 汪雄
     * @Date :
    */
    @PostMapping("ProgrammedeleteLogical")
    public Rsp ProgrammedeleteLogical(@RequestBody Programme programme,
                             @RequestHeader("token")String token){
        return programmeService.deleteSomeLogicalByCondition(programme);
    }


}
